main: Fix crossing event generation for parented roots
authorMatthias Clasen <mclasen@redhat.com>
Tue, 19 Mar 2019 23:12:55 +0000 (19:12 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 20 Mar 2019 01:33:38 +0000 (21:33 -0400)
We were walking the parent chain here, which now
always needs to consider whether it should stop
at roots. Like this one should.

The symptom was that a label with a popup attached to
it would end up with an unintentional focus ring that
would not go away.

gtk/gtkmain.c

index b435c489a37b4e82be7c405793c9076dff6de5d2..250a2063c70b04c2ab3db4eb0c9f191817f9c302 100644 (file)
@@ -1418,6 +1418,7 @@ synth_crossing (GtkWidget       *widget,
 
   if (gdk_event_get_event_type (source) == GDK_FOCUS_CHANGE)
     {
+g_print ("focus %s: %s\n", enter ? "in" : "out", G_OBJECT_TYPE_NAME (widget));
       event = gdk_event_new (GDK_FOCUS_CHANGE);
       event->focus_change.in = enter;
       event->focus_change.mode = crossing_mode;
@@ -1521,7 +1522,7 @@ gtk_synthesize_crossing_events (GtkRoot         *toplevel,
           if (widget != ancestor || widget == old_target)
             synth_crossing (widget, GTK_WIDGET (toplevel), FALSE,
                             old_target, new_target, event, notify_type, mode);
-          if (widget == ancestor)
+          if (widget == ancestor || widget == GTK_WIDGET (toplevel))
             break;
           widget = gtk_widget_get_parent (widget);
         }
@@ -1536,7 +1537,7 @@ gtk_synthesize_crossing_events (GtkRoot         *toplevel,
       while (widget)
         {
           widgets = g_slist_prepend (widgets, widget);
-          if (widget == ancestor)
+          if (widget == ancestor || widget == GTK_WIDGET (toplevel))
             break;
           widget = gtk_widget_get_parent (widget);
         }